package com.jxsm.service.impl;

import com.jxsm.dao.ContractDao;
import com.jxsm.page.Page;
import com.jxsm.pojo.Contract;
import com.jxsm.service.ContractService;
import com.jxsm.pojo.ContractVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

/**
 * Created by Administrator on 2016/11/1.
 */
@Service
public class ContractServiceImpl implements ContractService {
    @Autowired
    private ContractDao contractDao;
    public void insert(Contract entity) {
        entity.setId(UUID.randomUUID().toString());
        entity.setState(1);
        contractDao.insert(entity);
    }

    public void update(Contract entity) {
            contractDao.update(entity);
    }

    public void deleteById(Serializable id) {
        contractDao.deleteById(id);
    }

    public void delete(Serializable[] id) {
        contractDao.delete(id);
    }

    public List<Contract> findPage(Page page) {
        return contractDao.findPage(page);
    }

    public List<Contract> find(Map map) {
        return contractDao.findAll(map);
    }

    public Contract get(Serializable id) {
        return contractDao.get(id);
    }

    public void start(Serializable[] id) {
        Map<String ,Object> map=new HashMap();
        map.put("state",1);
        map.put("ids",id);
        contractDao.updateState(map);
    }

    public void stop(Serializable[] id) {
        Map<String ,Object> map=new HashMap();
        map.put("state",0);
        map.put("ids",id);
        contractDao.updateState(map);
    }

    public ContractVO view(String contractId) {
        return contractDao.view(contractId);
    }

}
